package it.polimi.traveldream.entities;

import it.polimi.traveldream.CreatedPackageDTO;
import it.polimi.traveldream.PackageDTO;

import java.io.Serializable;

import javax.persistence.*;

import java.util.Date;
//import java.util.Date;
import java.util.List;


/**
 * The persistent class for the package database table.
 * 
 */
@Entity
@NamedQuery(name="Package.findAll", query="SELECT p FROM PackageBase p")
public class PackageBase implements Serializable {
	private static final long serialVersionUID = 1L;

	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	private int id;
	
	private String nome;
	
	private String descrizione;
	
	//private Date datainizioviaggio;
	
	private String citta;
	
	private int durataviaggio;
	
	private byte disponibile;

	private byte inOfferta;
	
	private double prezzo;
	

	
	// -------------------------------------------------------------------------
	


	public PackageBase() {
	}
	
	public PackageBase(CreatedPackageDTO createdPackageDTO){
		super();
		this.id=createdPackageDTO.getId();
		this.nome=createdPackageDTO.getNome();
		this.descrizione=createdPackageDTO.getDescrizione();
		this.citta=createdPackageDTO.getCitta();
		this.durataviaggio=createdPackageDTO.getDurataViaggio();
		this.disponibile=createdPackageDTO.getDisponibile();
		this.inOfferta=createdPackageDTO.getInOfferta();
		this.prezzo=createdPackageDTO.getPrezzo();
		/*this.excursions=createdPackageDTO.getExcursion();
		this.hotels=createdPackageDTO.getHotel();
		this.transportsandata=createdPackageDTO.getTransportsAndata();
		this.transportsritorno=createdPackageDTO.getTransportsRitorno();*/
	}

	
	public String getCitta() {
		return citta;
	}

	public void setCitta(String citta) {
		this.citta = citta;
	}
	
	public int getId() {
		return this.id;
	}

	public void setId(int id) {
		this.id = id;
	}
	
	
	public String getNome() {
		return nome;
	}

	public void setNome(String nome) {
		this.nome = nome;
	}

	public byte getDisponibile() {
		return this.disponibile;
	}

	public void setDisponibile(byte disponibile) {
		this.disponibile = disponibile;
	}

	public byte getInOfferta() {
		return this.inOfferta;
	}

	public void setInOfferta(byte inOfferta) {
		this.inOfferta = inOfferta;
	}

	public double getPrezzo() {
		return prezzo;
	}

	public void setPrezzo(double prezzo) {
		this.prezzo = prezzo;
	}
	
	
	/*public Date getDatainizioviaggio() {
		return datainizioviaggio;
	}

	public void setDatainizioviaggio(Date datainizioviaggio) {
		this.datainizioviaggio = datainizioviaggio;
	}*/

	public String getDescrizione() {
		return descrizione;
	}

	public void setDescrizione(String descrizione) {
		this.descrizione = descrizione;
	}

	public int getDurataviaggio() {
		return durataviaggio;
	}

	public void setDurataviaggio(int durataviaggio) {
		this.durataviaggio = durataviaggio;
	}


    
	//bi-directional many-to-one association to Custompackage
	@OneToMany(mappedBy="packageBase")
	private List<Custompackage> custompackages;

 
	//bi-directional many-to-many association to Excursion
	@ManyToMany
	@JoinTable(name="packagebase_excursion", joinColumns={@JoinColumn(name="PackageBase_ID")}, inverseJoinColumns={@JoinColumn(name="excursions_ID")})
	private List<Excursion> excursions;

	//bi-directional many-to-many association to Hotel
	@ManyToMany
	@JoinTable(name="packagebase_hotel", joinColumns={ @JoinColumn(name="PackageBase_ID")}, inverseJoinColumns={@JoinColumn(name="hotels_ID")})
	
	
	private List<Hotel> hotels;

	//bi-directional many-to-many association to Transport
	@ManyToMany
	@JoinTable(name="packagebase_transporta", joinColumns={@JoinColumn(name="PackageBase_ID")}, inverseJoinColumns={@JoinColumn(name="transportsandata_ID")})
	private List<Transport> transportsandata;
	
	@ManyToMany
    @JoinTable(name="packagebase_transport",joinColumns={@JoinColumn(name="PackageBase_ID")}, inverseJoinColumns={@JoinColumn(name="transportsritorno_ID")})
	private List<Transport> transportsritorno;

	

	/*public List<Custompackage> getCustompackages() {
		return this.custompackages;
	}

	public void setCustompackages(List<Custompackage> custompackages) {
		this.custompackages = custompackages;
	}

	public Custompackage addCustompackage(Custompackage custompackage) {
		getCustompackages().add(custompackage);
		custompackage.setPackage(this);

		return custompackage;
	}

	public Custompackage removeCustompackage(Custompackage custompackage) {
		getCustompackages().remove(custompackage);
		custompackage.setPackage(null);

		return custompackage;
	}*/

	public List<Excursion> getExcursions() {
		return this.excursions;
	}

	public void setExcursions(List<Excursion> excursions) {
		this.excursions = excursions;
	}

	public List<Hotel> getHotels() {
		return this.hotels;
	}

	public void setHotels(List<Hotel> hotels) {
		this.hotels = hotels;
	}

	public List<Transport> getTransports() {
		return this.transportsandata;
	}

	public void setTransports(List<Transport> transports) {
		this.transportsandata = transports;
	}

	public List<Transport> getTransportsritorno() {
		return transportsritorno;
	}

	public void setTransportsritorno(List<Transport> transportsritorno) {
		this.transportsritorno = transportsritorno;
	}

}